<?php

namespace App\Models\Config;

use App\Models\Role;
use Illuminate\Database\Eloquent\Model;

class Channels extends Model
{
    //字段白名单
    protected $fillable = [
        'game_id', 'channel_id', 'channel_name', 'server_ip', 'port', 'status'
    ];

    //表名
    protected $table = 'mc_game_channels';

    public function game()
    {
        return $this->belongsTo(Games::class, 'game_id', 'game_id');
    }

    public function roles()
    {
        return $this->belongsToMany(Role::class, 'role_channel')->withTimestamps();
    }
}
